home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / prgtools / tn2.zip / MORTGAGE.T < prev    next >
Text File  |  1996-11-15  |  1KB  |  53 lines

  1. %
  2. % "mortgage.t" generate listing of monthly mortgage
  3. % principle and interest
  4. %
  5. %   Sample program for the T Interpreter by:
  6. %
  7. %   Stephen R. Schmitt
  8. %   962 Depot Road
  9. %   Boxborough, MA 01719
  10. %
  11.  
  12. program
  13.  
  14.     var balance, f,
  15.         payment, i,
  16.         interest_rate,
  17.         interest,
  18.         principle : real
  19.     var years, month, n : int
  20.         
  21.     prompt "loan amount $"
  22.     get balance
  23.     put "loan    = $", balance:2
  24.  
  25.     prompt "interest rate %"
  26.     get interest_rate
  27.     put "apr     = ", interest_rate, "%"
  28.     prompt "years to pay"
  29.     get years
  30.     put "term    = ", years * 12, " months"
  31.  
  32.     i := interest_rate / 1200
  33.     n := years * 12
  34.     f := balance * i * ( 1 + i )^n / ( ( 1 + i )^n - 1 )
  35.     payment := 0.01 * ceil( 100 * f )
  36.     put "payment = $", payment:2
  37.     put ""
  38.     put "  #   principle    interest     balance"
  39.     put "---------------------------------------"
  40.     n := 0
  41.     loop
  42.  
  43.         incr n
  44.         interest := 0.01 * round( 100 * balance * i )
  45.         principle := payment - interest
  46.         balance := balance + interest - payment
  47.         put n:3, principle:12:2, interest:12:2, balance:12:2
  48.  
  49.         exit when balance <= 0.0
  50.  
  51.     end loop
  52.  
  53. end program